<?php

/**
 * descript:
 * User: blue
 * Date: 2018/9/21 9:08
 */

namespace app\library\server;

use app\library\except\AuthException;
use rabbit\base\Auth;

class Authority
{
    /*检查权限*/
    public static function checkAuth(){
        //先检查是否登录->然后验证权限
        $token=TokenS::tokenVerify();
        $tokenArr=json_decode($token,true);
        $auth=new Auth();
        //这段代码有问题,controller获取的控制
        $controller=explode('.',request()->controller());
        $rule=request()->module().'/'.strtolower($controller[1]).'/'.request()->action();
        $res=$auth->check($rule,$tokenArr['id']);
        if(!$res) throw new AuthException('没有权限');
        return true;
    }


}